const Editor = require('../../../src/index');
const Util = Editor.Util;
const dom = document.createElement('div');
const expect = require('chai').expect;
const data = require('../../../demos/data/sample.json');
document.body.appendChild(dom);

describe('toolbar test', () => {
  const editor = new Editor();
  const dom = Util.createDOM(`
    <div>
      <div id="page"></div>
      <div id="toolbar" style="margin-left: 20px;">
        <button data-command="zoomIn" class="command">放大</button>
        <button data-command="zoomOut" class="command">缩小</button>
      </div>
    </div>
  `);
  document.body.appendChild(dom);
  const toolbar = new Editor.Toolbar({
    container: 'toolbar',
    width: 120,
    height: 120
  });
  const page = new Editor.Flow({
    graph: {
      container: 'page',
      height: 500,
      width: 500
    }
  });
  page.read(data);
  editor.add(page);
  editor.add(toolbar);

  it('init', () => {
    const toolbarContainer = document.getElementById('toolbar');
    expect(toolbarContainer.childElementCount).not.equal(0);
    editor.destroy();
    dom.destroy();
  });
});
